package com.sinosoft.tcmemr.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.sinosoft.tcmemr.entity.DiagnoseEntity;
import com.sinosoft.tcmemr.entity.PatientCaseEntity;
import com.sinosoft.tcmemr.manager.PatientCaseManager;

@Service
public class PatientCaseService {

	@Autowired
	private PatientCaseManager patientCaseManager; 
	
	/**
     * 增加病历信息
     * @param patient
     * @return true/false
     */
    public boolean addPatientCase(PatientCaseEntity patientcase){
    	return patientCaseManager.insertSelective(patientcase);
    }
    
    /**
     * 增加病历
     * @param patientcase 病历信息
     * @param doctorID  医生ID
     * @param diagnoseList  诊断列表
     * @return  true/false
     */
    public boolean addPatientCase(PatientCaseEntity patientcase,
    		Integer doctorID,String drName,List<DiagnoseEntity> diagnoseList){
    	return patientCaseManager.addPatientCase(patientcase, doctorID, drName, diagnoseList);
    }
    
    /**
     * 查看病历信息
     * @param id
     * @return true/false
     */
    public PatientCaseEntity getPatientCaseByPrimaryKey(Integer id){
    	return patientCaseManager.selectByPrimaryKey(id);
    }
    
    /**
     * 查看病历信息
     * @param patientid
     * @return 病历列表
     */
    public List<PatientCaseEntity> getPatientCaseByPatientID(Integer patientid){
    	return patientCaseManager.selectByPatientID(patientid);
    }
    
    /**
     * 更新病历信息
     * @param patientcase
     * @return true/false
     */
    public boolean updateByPrimaryKeySelective(PatientCaseEntity patientcase){
    	return patientCaseManager.updateByPrimaryKeySelective(patientcase);
    }
    
    /**
     * 查询该病人看同一个医生 当天的病历
     * @param patientid 病人ID
     * @param drName 医生姓名
     * @param clinicdate 诊断日期
     * @return PatientCaseEntity
     */
    public PatientCaseEntity getPatientCaseByToday(Integer patientid, String drName,Date clinicdate ){
    	return patientCaseManager.selectByToday(patientid, drName, clinicdate);
    }
    
    /**
     * 获取该病人可修改的病历
     * @param patientid 病人ID
     * @param doctorID 医生ID
     * @return PatientCaseEntity
     */
    public PatientCaseEntity getWritePatientCase(Integer patientid, Integer doctorID ){
    	return patientCaseManager.getWritePatientCase(patientid, doctorID);
    }
    
}
